<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
    <button id="addButton">点击按钮</button>
    <div id="container"></div>
</body>

<script>
    // 计数器
    var click_time = 0;
    // 获取按钮和容器元素的引用
    const addButton = document.getElementById('addButton');
    const container = document.getElementById('container');

    // 添加点击事件监听器
    addButton.addEventListener('click', function () {
        // 创建一个新的 <p> 元素
        const newParagraph = document.createElement('p');
        newParagraph.textContent = '你点击了按钮' + click_time + '次';
        click_time++;
        // 将新的 <p> 元素添加到容器中
        container.appendChild(newParagraph);
    });

</script>

</html>